package cn.da.shuai.cool.system.service.util;

import cn.da.shuai.cool.security.util.SecurityUtil;
import cn.da.shuai.cool.system.service.domain.CoolUserDetails;
import cn.da.shuai.cool.system.model.entity.user.CoolUser;

public class UserUtil {

    public static CoolUser getCurrentUser() {
        CoolUserDetails currentUser = (CoolUserDetails)SecurityUtil.getCurrentUser();
        if (currentUser == null) {
            return null;
        }
        return currentUser.getCoolUser();
    }

    public static Integer getUserId() {
        CoolUser currentUser = getCurrentUser();
        if (currentUser == null) {
            return null;
        }
        return currentUser.getId();
    }

    public static String getUsername() {
        CoolUser currentUser = getCurrentUser();
        if (currentUser == null) {
            return null;
        }
        return currentUser.getUsername();
    }
}
